package aop.test.proxy.autoproxy;

import cn.stimd.spring.aop.support.StaticMethodMatcherPointcut;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationAttributes;

import java.lang.reflect.Method;

/**
 * Created by Stimd
 * 项目地址：https://gitee.com/stimd/spring-wheel
 * 公众号：Java编程探微
 */
public class LoggerPointcut extends StaticMethodMatcherPointcut {

    @Override
    public boolean matches(Method method, Class<?> targetClass) {
        //检查方法上是否声明了@Logger注解
        AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(method,
                Logger.class, false, false);
        return attributes != null;
    }
}
